package com.java.mytools.controller;

import com.java.mytools.service.SftpService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author wangning
 * @create 2021-08-12 10:39
 * 上传下载
 */
@Api("使用sftp进行文件的导入导出")
@RestController
@RequestMapping("/sftp")
public class SftpController {

	@Autowired
	private SftpService sftpService;

	@GetMapping("download")
	public void download(HttpServletRequest request, HttpServletResponse response, String filePath) {
		sftpService.download("");
	}

	@PostMapping("upload")
	@ApiOperation("文件上传")
	@ApiImplicitParam(name = "file", value = "文件", required = true, dataType = "MultipartFile")
	public Map<String, String> upload(MultipartFile file) {
		return sftpService.upload(file);
	}

}
